﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using ZhiAo.WebLib.Data;

namespace ZhiAo.Management.Data
{
    public class UserQuery
    {
        public static DataTable GetFunctions(string userId)
        {
            string sql = "select f.functionid,f.parentid,f.name,f.code,f.url,f.showinmenu from powerplat.dbo.SSO_FUNCTION f " +
                        "inner join powerplat.dbo.SSO_ENTITY2FUNC e " +
                        "on f.code=e.functioncode " +
                        " where e.entityid='" + userId + "'";
            return DBHelper.GetDataTable(sql);
        }

        public static string GetFirstCityId(string userId)
        {
            string sql = @"select top 1 f.functionid from powerplat.dbo.SSO_FUNCTION f
                        inner join powerplat.dbo.SSO_ENTITY2FUNC e
                        on e.functioncode=f.code
                        where e.entityid='{0}' and 
                        f.functionid in ('0a537b8cd16546fd8f82c66912313285','5de5e9e9e47942c8b10892408c8a147e','7dbd256b988e4aee85455b186ab14b7f',
                        '9b3ab7023b0549b8a3fef11a3433e28b','ad951c329337440ea5e50929d7773c63','b6df90d54141448fb5b47104e6b0bf7b',
                        'bbedf04807c742fb9f4d923ac32487af','d3071813909f4eaab82f94f93867e90d','e63d3608b84342e192aabaa00d11cb76','fc536f26ad064a9d8c4abc3d60c90777')";
            sql=string.Format(sql,userId);
            DataTable dt= DBHelper.GetDataTable(sql);
            if (dt != null && dt.Rows.Count > 0)
            {
                return dt.Rows[0][0].ToString();
            }
            return string.Empty;
        }
    }
}
